<?php

namespace app\index\controller;

use app\model\Config;
use think\exception\ValidateException;
use app\model\AppMenu;

class AppmenuController extends Base
{

    public function list()
    {
        $data = AppMenu::getAppMenu($this->userInfo);
        $commonConfig = Config::getconfig('common');
        $examineArr = ['订单','需求'];
        $list = $data['list'];
        $data['list'] = [];
        foreach ($list as $k => $v){
            if($commonConfig['examine_status'] == 1){
                if(in_array($v['text'], $examineArr, true)){
                    unset($v);
                }else{
                    $data['list'][] = $v;
                }
            }else{
                $data['list'][] = $v;
            }

        }
        return $this->json(['data' => $data]);
    }
    public function getindex()
    {
        $where['weid'] = weid();
        $where['is_index'] = 1;
        $where['tid'] = 0;
        $where['module'] = 'bottom';

        $data = AppMenu::where($where)
            ->order('sort asc')
            ->find();
        if (empty($data)) {
            $data['url'] = '/pages/index/index';
        } else {
            $data = $data->toArray();
        }

        return $this->json(['data' => $data]);
    }
}
